home *** CD-ROM | disk | FTP | other *** search
Wrap
package com.ibm.ivb.jface.plus; import com.ibm.ivb.jface.NullEvent; import com.ibm.ivb.jface.Tool; import com.ibm.ivf.ui.browser.interfaces.IElement; import com.ibm.ivf.ui.browser.interfaces.IProperty; import com.ibm.ivf.ui.browser.interfaces.SetPropertyVetoException; import com.ibm.ivf.ui.browser.model.SimpleProperty; import java.awt.Component; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTextPane; import javax.swing.text.DefaultStyledDocument; import javax.swing.text.StyleContext; import javax.swing.text.StyledDocument; public class TextViewer extends ToolViewer { private static final String fgIBMCopyright = "(c) Copyright IBM Corporation 1998"; protected JScrollPane scrollPane; protected JTextPane textPane = this.createTextPane(); protected StyleContext styleContext = this.createStyleContext(); protected StyledDocument document = this.createStyledDocument(); private boolean modified = false; // $FF: renamed from: dh com.ibm.ivb.jface.plus.TextViewer.DocumentHandler private DocumentHandler field_0 = new DocumentHandler(this); public TextViewer() { JTextPane var10000 = this.textPane; this.getClass(); ((Component)var10000).addMouseListener(new ToolViewer.PopupListener(this)); this.textPane.addCaretListener(this.field_0); } protected StyleContext createStyleContext() { return new StyleContext(); } protected StyledDocument createStyledDocument() { return new DefaultStyledDocument(this.styleContext); } protected JTextPane createTextPane() { return new JTextPane(this.document); } public void domainChanged(IElement var1, String var2, IElement var3) { if (var1 != null && (var3 == null || var3 != ((ToolViewer)this).getCurrentElement())) { if (var1 != ((ToolViewer)this).getCurrentElement() || var2 != null && !var2.equals(((ToolViewer)this).getCurrentPropertyName())) { if (var1 != null && var3 == null && (var2.equals("name") || var2.equals("icon")) && var1 == ((ToolViewer)this).getCurrentElement()) { ((Tool)this).setTitleIcon(var1.getIcon()); ((Tool)this).setTitle(var1.getName()); } } else { this.textPane.setText(((ToolViewer)this).getCurrentProperty().toString()); this.textPane.repaint(); } } else { ((ToolViewer)this).updateInput(((ToolViewer)this).getCurrentElement()); } } public Component getPrintableView() { return this.textPane; } protected String getSavePromptMessage() { return ((ToolViewer)this).getCurrentElement().getName() + " " + ((ToolViewer)this).getCurrentProperty().toString() + " modified. Do you want to save?"; } public Component getView() { return ((ToolViewer)this).createScrollPane(this.textPane); } public void inputChanged(IElement var1, IProperty var2) { if (this.isModified()) { this.promptDocumentSave(); } this.textPane.getDocument().removeDocumentListener(this.field_0); if (var1 != null && var2 != null) { this.textPane.setText(var2.toString()); this.textPane.getDocument().addDocumentListener(this.field_0); } else { ((Tool)this).fireLinkEvent(new NullEvent(this)); this.textPane.setText(""); } this.textPane.repaint(); } public boolean isModified() { return this.modified; } protected void promptDocumentSave() { int var1 = JOptionPane.showConfirmDialog(this.getView(), this.getSavePromptMessage(), "", 0); if (var1 == 0) { this.save(); } } public void save() { IElement var1 = ((ToolViewer)this).getCurrentElement(); String var2 = ((ToolViewer)this).getCurrentPropertyName(); if (var1 != null && var2 != null) { try { var1.setProperty(var2, new SimpleProperty(this.textPane.getText())); this.modified = false; } catch (SetPropertyVetoException var3) { } } } // $FF: synthetic method static boolean access$0(TextViewer var0) { return var0.modified; } // $FF: synthetic method static void access$1(TextViewer var0, boolean var1) { var0.modified = var1; } }